package com.lzc.springcloud.msconsumeruser.feign;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;

import com.lzc.springcloud.config.Configuration1;
import com.lzc.springcloud.msconsumeruser.entity.User;

import feign.Param;
import feign.RequestLine;

//@FeignClient(name = "ms-eureka-provider-user-client") // 有集成eureka时，根据name值去eureka获取
//@FeignClient(name = "${feign.client.user.name}", url = "${feign.client.user.url}") // 没有集成eureka时，可以定义url进行调用
@FeignClient(name = "${feign.client.user.name}", url = "${feign.client.user.url}", configuration = Configuration1.class, fallback = UserFeignClientFallback.class)
public interface UserFeignClient {

	@RequestLine("GET /getUser/{id}")
	public User getUser(@Param("id") Integer id);

}

@Component
class UserFeignClientFallback implements UserFeignClient {

	@Override
	public User getUser(Integer id) {
		User user = new User();
		user.setId(0);
		return user;
	}

}
